﻿using System;

namespace BLL.Utils
{
    public static class NullExtensions
    {
        public static TValue With<TObj, TValue>(this TObj obj, Func<TObj, TValue> getter)
            where TObj : class
            where TValue : class
        {
            return obj == null ? null : getter(obj);
        }

        public static void Do<TObj>(this TObj obj, Action<TObj> action) where TObj : class
        {
            if (obj != null)
                action(obj);
        }
    }
}